<%-- 
    Document   : left_menu
    Created on : 20-10-2011, 03:08:25
    Author     :  HIT
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="POJO.Thamso"%>
<%@page import="POJO.Hinhanh"%>
<%@page import="POJO.Sanpham"%>
<%@page import="POJO.Gianhang"%>
<%@page import="BUS.ThamsoBUS"%>
<%@page import="java.util.List"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>

    </head>
    <body>
        <%
            Gianhang gh = (Gianhang) request.getAttribute("gianhang");
            if (gh != null) 
            {
                Sanpham sp = (Sanpham) request.getAttribute("sanpham");
                List<Hinhanh> dsha = (List<Hinhanh>) request.getAttribute("dshinhanh");
                String giaTotHomNay=sp.getGioiThieu();
                String giaBan=gh.getGiaBan().toString();
                double giaGoc=gh.getGiaGoc();
                String khuyenMai=gh.getKhuyenMai().toString();
                String diemnoibat=sp.getDiemNoiBat();
                String diaChi=sp.getDiaChi();
                String tenSanPham=sp.getTenSanPham();
                String soLuongNguoiMua=gh.getSoLuongBan().toString();
                int soLuongConLai=gh.getSoLuongToiDa()-gh.getSoLuongBan();
        %>
       
        <div id="DealInfo" class="detail-deal" itemscope="" itemtype="" style="overflow:visible">
            <div style="width:678px">
                <h2 itemprop="name" style="font-size:19px" class="titledeal">
                     <%=giaTotHomNay %>
                </h2>
            </div>  
            <div class="purchase minmax"> 


                <div class="detail-deal-photo">

                    <div id="wrapper">

                        <a href="" id="dev7link" title="Go to dev7studios">dev7studios</a>

                        <div class="slider-wrapper theme-default">
                            <div class="ribbon"></div>
                            <div id="slider" class="nivoSlider">
                                <%
                                    for(int i=0;i<dsha.size();i++)
                                                                               {
                                        String duongdan = dsha.get(i).getDuongDan();
                                %>
                                <img src="<%=duongdan %>" alt="" title="<%=tenSanPham %>" />
                                
                           <%
                                                     }
                           %>
                            </div>     
                        </div>

                    </div>                     


                </div> 

                <div class="box-white-info" itemprop="" itemscope="" itemtype="">
                    <div class="fullview-links" id="divLinkSharing" style="overflow:visible;padding-left:5px;">
                        <div class="detail-deal-info">
                            <p itemprop="price" class="margin-negative">
                                <%=giaBan %><strong itemprop="currency">VNĐ</strong>
                            </p>
                            <p >
                            <form action="" >
                                <button type="submit" value="Mua" id="view-button2">

                                </button>
                            </form>
                            </p>
                            <div class="box-white-info-price">
                                <p>Giá gốc: 
                                    <span><%=giaGoc %></span> VNĐ
                                </p>
                            </div>
                            <div class="box-white-info-sale">
                                <div class="box-white-info-save">
                                    <span class="number"><%=khuyenMai %>%</span>
                                    <span>tiết kiệm</span>
                                </div>
                                <div class="box-white-info-buyer">
                                    <span class="number"><%=soLuongNguoiMua %></span>
                                    <span>người mua</span>
                                </div>
                                <div class="box-white-info-time">
                                    <span class="number" id="Time_CountDown_0">






                                    </span>                                              


                                    <span>thời gian còn lại</span>
                                </div>
                                <div class="clear">

                                </div>

                            </div>
                            <div class="progess-bar">
                                <div class="bg-progess-bar">
                                    Chỉ còn lại <%=soLuongConLai %> cơ hội

                                </div>

                            </div>
                        </div>


                    </div>

                </div>

                <div class="clear">

                </div>
                <ul class="detail-deal-condi">
                    <li style="padding-bottom:20px;">
                        <p class="title">Điểm nổi bật:</p>
                        <p>
                            <%=diemnoibat %>
                        </p>
                    </li>	
                    <li>	
                        <p class="title"><strong><br>
                               <%=diaChi %></strong>
                        </p>
                    </li> 
                </ul>
            </div>
        </div>

        <%
            }
        %>
        
        
        
        <script type="text/javascript">
            var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") 
            var dateFuture;
            <%                
                
                    String tam = gh.getNgayHetHan().toString();
                    String[] arr = tam.split("-");
            %>
                yr=<%=arr[0]%>;
                mo=<%=arr[1]%>;
                da=<%=arr[2]%> ;
                futurestring=montharray[mo-1]+" "+da+", "+yr ;
                dateFuture=Date.parse(futurestring);
           
           
        </script>
        <script type="text/javascript">
            
            function GetCount(ddate,iid){

                dateNow = new Date();    //grab current date
                amount = ddate - dateNow.getTime();    //calc milliseconds between dates
                delete dateNow;

                // if time is already past
                if(amount < 0){
                    document.getElementById(iid).innerHTML="Hết hạn !";
                }
                // else date is still good
                else{
                    days=0;hours=0;mins=0;secs=0;out="";

                    amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs

                    days=Math.floor(amount/86400);//days
                    amount=amount%86400;

                    hours=Math.floor(amount/3600);//hours
                    amount=amount%3600;

                    mins=Math.floor(amount/60);//minutes
                    amount=amount%60;

                    secs=Math.floor(amount);//seconds

                    if(days > 0)
                    {
                        out += days +" "+((days==1)?"ngày":"ngày");
                    }
                    else
                    {
                        if(hours != 0)
                        {
                            out += hours +" "+((hours==1)?"":"")+":";
                        }
                        out += mins +" "+((mins==1)?"":"")+":";
                        out += secs +" "+((secs==1)?"":"");
                        
                    }
                    
                    document.getElementById(iid).innerHTML=out;

                    setTimeout(function(){GetCount(ddate,iid)}, 1000);
                }
            }

            window.onload=function(){
           
                    GetCount(dateFuture, 'Time_CountDown_0');
                
            
                    //you can add additional countdowns here (just make sure you create dateFuture2 and countbox2 etc for each)
                };
        </script> 
    </body>
</html>
